<%--
  Created by IntelliJ IDEA.
  User: kkk
  Date: 2022/8/1
  Time: 15:09
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <style>
        .div{
            margin-left: 420px;
            width: 740px;
            height: 500px;
        }
    </style>
    <base href="${pageContext.request.contextPath}/">
    <script src="js/jquery.js"></script>
    <%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
</head>
<body>
    <div class="div">
        <form action="ResumeListServlet" style="text-align: center">
            <h2>个人简历信息列表</h2>
            性别：<input type="radio" name="sex" title="男" value="男">男
                 <input type="radio" name="sex" title="女" value="女">女
                 <input type="radio" name="sex" title="" value="">全部
                 <input type="submit" value="查询">
            <input style="margin-left: 150px" type="button" onclick="javaoscript:location.href='ResumeAdd.jsp'" value="新增个人简历信息">
        </form>
        <table border="1">
            <tr class="header">
                <th>姓名</th>
                <th>性别</th>
                <th>籍贯地址</th>
                <th>出生时间</th>
                <th>联系电话</th>
                <th>毕业学校</th>
                <th>简历状态</th>
                <th>操作</th>
            </tr>
            <c:forEach items="${sessionScope.list}" var="resume">
                <tr>
                    <td>${resume.userName}</td>
                    <td>${resume.sex}</td>
                    <td>${resume.birth}</td>
                    <td>${resume.address}</td>
                    <td>${resume.telephone}</td>
                    <td>${resume.school}</td>
                    <c:if test="${resume.status==1}">
                        <td>公开</td>
                    </c:if>
                    <c:if test="${resume.status==0}">
                        <td>保密</td>
                    </c:if>
                    <td><a  onclick="deleteUser(${resume.id})">删除</a></td>
                </tr>
            </c:forEach>
        </table>
    </div>
    <script>
        $(function () {
            $.ajax({
                url:"ResumeListServlet",
                type:"get"
            })
            $('tr:first').css("backgroundColor","darkgray")
            $('tr:odd').css("backgroundColor","cornsilk")
            $('tr:even').css("backgroundColor","grey")

        })
        function deleteUser(id){
            var result= confirm("确认删除吗？");
            if (result) {
                $.get("ResumeDelServlet","id="+id,function (data) {
                    if (data==="true") {
                        alert("删除成功")
                        location.href="ResumeListServlet";
                    }else {
                        alert("删除失败")
                        location.href="ResumeListServlet";
                    }

                })
            }
        }
        $.get("ResumeListServlet");
    </script>
</body>
</html>
